package com.videoshare.multimedia.dao;

import com.sapientia.multimedia.MimeTypeBean;
import com.sapientia.user.dao.MyBasicDataSource;
import com.sapientia.rdfmodel.bean.DCFormatBean;
import javax.sql.*;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.framework.Test;
import java.sql.Connection;
import java.util.*;


public class MultimediaDAOImplTest extends TestCase {
	Connection conn = null;
	MultimediaDAOImpl dao = null;
	
	public MultimediaDAOImplTest(String testName)
	{
		super(testName);
	}
	
	public static Test suite() 
	{
		TestSuite suite = new TestSuite("Test for sapientiatv");
		suite.addTest(new MultimediaDAOImplTest("testGetMimeType"));
		return suite;
	}

	protected void setUp() throws Exception {
		
		super.setUp();
		javax.sql.DataSource datasource = new MyBasicDataSource().setupDataSource();
		conn = datasource.getConnection();
		dao = new MultimediaDAOImpl(conn);
		
	}

	protected void tearDown() throws Exception {
		
		conn.close();
		super.tearDown();
		
	}

	
	public void testGetMimeType() {

		MimeTypeBean bean  = dao.getMimeType();
		
		Iterator ivideo = bean.getVideoStreamMimeTypeList().iterator();
		while( ivideo.hasNext())
		{
			DCFormatBean videoType = (DCFormatBean) ivideo.next();
		
			System.out.println("tipo video: " + videoType.getVideoStreamMimeType());
		}
		
		Iterator iaudio = bean.getAudioStreamMimeTypeList().iterator();
		while( iaudio.hasNext())
		{
			DCFormatBean audioType = (DCFormatBean) iaudio.next();
		
			System.out.println("tipo audio: " + audioType.getAudioStreamMimeType());
		}
	}
	
}	
	